package org.zoomdev.zoom.dao.column;

import org.zoomdev.zoom.common.utils.HexUtils;
import org.zoomdev.zoom.dao.adapters.DataAdapter;

/**
 * vo byte[]
 * db string
 */
public final class ByteArray2HexStringAdapter implements DataAdapter<byte[], String> {

    @Override
    public String toDbValue(byte[] bytes) {
        if (bytes == null) return null;
        return HexUtils.encodeHexStr(bytes);
    }

    @Override
    public byte[] toEntityValue(String s) {
        if (s == null) return null;
        return HexUtils.decodeHex(s);
    }
}
